﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FmcWebsite.Core;

namespace Tester
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DBConnect.UseMySql("localhost", "cms", "cmsuser", "cmsuser");
            MessageBox.Show("Connection OK");
            var c = Category.ById(3);
            var arts = Article.ByCategory(c, true);
            MessageBox.Show(string.Format("Article found ({0}): {1}", c.Name, arts.Count()));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            var arts = Article.GetAll();
            MessageBox.Show("Articles retrieved: " + arts.Count().ToString());

            //arts.First().Update();
            var n = new Article();
            n.Insert();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Multilang mm = new Multilang("");
            mm["EN"] = "Cat>";
            mm["NL"] = "Kat";
            mm["ID"] = "Kucing";
            MessageBox.Show(mm.Value);
            Multilang m2 = new Multilang(mm.Value);
            MessageBox.Show("Decoding succeeded." + m2["EN"]);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            DBConnect.UseMySql("localhost", "cms", "cmsuser", "cmsuser");
            Author author = Author.ById(1);
            pictureBox1.Image = author.Picture;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            DBConnect.UseMySql("localhost", "cms", "cmsuser", "cmsuser");
            var art = Article.ById(1);
            pictureBox1.Image = art.Images.First().Image;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            DBConnect.UseMySql("localhost", "cms", "cmsuser", "cmsuser");
            var art = Article.ById(2);

            Attachment.Insert(art, "josh", @"w:\Media\Audio\Josh Groban - Awake\Josh Groban Awake February Song.mp3");
            return;


            var aut = Author.ById(1);

            aut.Picture = Image.FromFile("pic.jpg");

            pictureBox1.Image = aut.Picture;

            aut.Update();

        }
    }
}
